import json
import requests
import UA模块
post_url = 'https://fanyi.baidu.com/sug'
### 伪装UA
headers = UA模块.main()
###post 请求参数处理
word = input('想获取哪个单词的注释呀：')
data = {
    'kw':word
}
###发起请求
response = requests.post(url=post_url,data=data,headers=headers)
###获取响应数据:json方法返回的是obj
dic_obj = response.json()
print(dic_obj)
###持久化存储
filename = word + '.txt'
fp = response.json()
fp = open(filename,'w',encoding='utf-8')
json.dump(dic_obj,fp=fp,ensure_ascii=False)

